import { request } from "../request";

const token = localStorage.getItem("token");

/**
 * 检查文件是否存在接口返回结构
 */
export interface CheckFileExistsRes {
    code: number;
    message: string;
    data: Record<string, unknown>;
    timestamp: Record<string, unknown>;
}

/**
 * 检查文件是否存在
 * @param objectKey 文件的唯一标识
 * @returns 检查结果
 */
export const checkFileExistsAPI = async (objectKey: string): Promise<CheckFileExistsRes> => {
    return request(`/api/file/exists`, {
        method: "get",
        headers: {
            Authorization: `Bearer ${token}`
        },
        params: {
            objectKey
        }
    });
};